package com.sinosoft.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author loujiang
 * @date 2020/12/20 3:49 下午
 * @NOTE:
 */

@RestController
public class TestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    /**
     * 测试服务发现订单微服务(user-trade)总是能够调用 用户(user-center)微服务
     *
     * @return 用户中心所有实例的地址信息
     */
    @GetMapping("test")
    public List<ServiceInstance> getInstances() {
        //查询指定服务到所有信息
        //查询用户微服务所有实例信息
        return this.discoveryClient.getInstances("user-center");
    }

}
